<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        html,body{
            height: 100%;
        }
        div{
            width: 400px;
            height: 300px;
            margin:auto;
            position: relative;
            top: 50%;
            margin-top: -150px;
        }
    </style>
    <script>
        let form;
        function load() {
            form = document.forms['frm'];
            form.commit.addEventListener('click',Check);
        }
        function Check() {
            let reg1 = /^[a-zA-Z][a-zA-Z0-9]+$/;
            let value = form.info1.value;
            form.info1.nextElementSibling.innerHTML = reg1.test(value) ?'':'姓名以字母开头';
            let reg2 = /^[a-zA-Z0-9]{4,8}$/;
            value = form.info2.value;
            form.info2.nextElementSibling.innerHTML = reg2.test(value) ?'':'密码为四到八位';
            let reg3 = /^([1-9]|[1-9]\d)$/;
            value = form.info3.value;
            form.info3.nextElementSibling.innerHTML = reg3.test(value) ?'':'年龄为1-100';
            let reg4 = /^(?!-)/;
            value = form.info4.value;
            form.info4.nextElementSibling.innerHTML = reg4.test(value) ?'':'请选择省份';
        }
    </script>
</head>
<body onload="load()">
<div><h1>用户注册</h1>
    <form name="frm">

        姓名：<input name="info1"><span style="color: red"></span><br/>
        密码：<input name="info2" type="password"><span style="color: red"></span><br/>
        年龄；<input name="info3" ><span style="color: red"></span><br/>
        省份：
        <select name="info4">
            <option name="">-请选择-</option>
            <option name="山西省">山西省</option>
            <option name="陕西省">陕西省</option>
            <option name="河南省">河南省</option>
            <option name="河北省">河北省</option>
            <option name="广东省">广东省</option>
        </select><span style="color:red"></span><br>
        <button name="commit" type="button">注册</button>
    </form>
</div>
</body>
</html>